The approaches described in this section could be pursued, but are not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated herein, the approaches described in this section are not prior art to the claims in this application and are not admitted to be prior art by inclusion in this section.
When information is to be transmitted over a computer network, such as a Local Area Network (LAN) or a Wide Area Network (WAN), the information may be inserted, or “encapsulated” into data packets, which are then forwarded, network element-by-network element, from source to destination. Encapsulation typically involves the addition of one or more headers to a data packet that contains a message or data. Each header may contain additional information about how the data packet is to be handled as it traverses a network.
Multiple layers of encapsulation may be employed when encapsulating information for transmission over a network. Each layer of encapsulation may correspond to a different protocol. For example, an application level protocol header such as a Hypertext Transfer Protocol (HTTP) header may be “prepended” to (i.e., added to the front of) a message that is to be transmitted to an application that uses HTTP. Next, a transport layer protocol header such as a Transport Control Protocol (TCP) header may be prepended to the HTTP header if the data packet is to be transmitted over a network that uses TCP. Then, a network layer protocol header such as an Internet Protocol (IP) header may be prepended to the TCP header if the data packet is to be transmitted over a network that uses IP. Finally, a data-link protocol header such as an Ethernet Protocol header may be prepended to the IP header if the data packet is to be transmitted over a network that uses the Ethernet Protocol.
Thus, a message may be prepended with multiple headers during the encapsulation process. The data packet, including the headers, may be forwarded from one network element or forwarding device to another network element or forwarding device. For example, a router may forward a data packet to another router. After a router receives a data packet, the router inspects the contents of the data packet's front-most header. The router may handle the data packet based on the contents of the header. Next, the router may inspect the contents of the data packet's next-to-front-most header, and handle the data packet based on the contents of that header. The router may inspect the contents of each header from the front-most header to the rear-most header in succession, and handle the data packet based on the contents of each such header.
In handling a data packet, a router may strip a header off of the front of the data packet. For example, if a data packet is to be forwarded through a network that uses the High-level Data Link Control (HDLC) Protocol rather than the Ethernet Protocol, the router may strip the Ethernet Protocol header off of the front of the data packet, so that the HDLC Protocol can be prepended to the data packet instead. The process of inspecting headers as described above, including the possible stripping of such headers, may be called “decapsulation.”
A router typically comprises multiple physical interfaces through which the router receives incoming data packets, and through which the router sends outgoing data packets. Different physical interfaces may be configured to send and/or receive different kinds of data packets. For example, a physical interface might be configured to send and receive only IP Version 4 (IPv4) packets. For another example, a physical interface might be configured to send and receive only IP Version 6 (IPv6) packets. A physical interface could be configured to send and receive both IPv4 and IPv6 packets.
As described in U.S. Pat. No. 6,601,106 B1, each physical interface may be associated with a separate “encapsulation chain” and a separate “decapsulation chain.” Each decapsulation chain comprises one or more successive chain elements that successively perform decapsulation functions on data packets as those data packets are passed through those chain elements. Each encapsulation chain comprises one or more successive chain elements that successively perform encapsulation functions on data packets as those data packets are passed through those chain elements. Each physical interface is associated with both an encapsulation chain and a decapsulation chain. Each physical interface is bi-directional.
A router may receive a data packet on a first of several physical interfaces. The router may pass the data packet through one or more chain elements of the decapsulation chain associated with the first physical interface. At some point during or following the data packet's progression through the first physical interface's decapsulation chain, the router may select, from among the router's multiple physical interfaces, a second physical interface through which the data packet needs to be transmitted in order to move the data packet towards the data packet's ultimate destination. Having made this determination, the router may provide the data packet to a selected chain element in the encapsulation chain that is associated with the second physical interface. The router may pass the data packet through one or more chain elements of the second physical interface's encapsulation chain. After emerging from the second physical interface's encapsulation chain's last chain element, the data packet may be transmitted out of the router through the second physical interface.
Formerly, all of a router's physical interfaces were consolidated on a single hardware “card”. However, modern distributed routers may comprise multiple separate interconnected cards, such as line cards or routing processors. Each such card contains separate processing and memory resources. Each such card may expose a separate subset of a router's physical interfaces. For each physical interface, the encapsulation and decapsulation chains associated with that physical interface are constructed on the same card that exposes that physical interface. A data packet may be forwarded from a decapsulation chain on a first card to an encapsulation chain on a second card. Thus, a data packet may be received on one of a first card's physical interfaces, and transmitted out on one of a second card's physical interfaces.
In addition to the physical interfaces described above, a router may comprise one or more virtual interfaces. None of a router's physical ports is a virtual interface per se. Virtual interfaces are embodied in data structures and other software elements, and receive data packets from chains that are associated with physical interfaces. An example of a virtual interface is a “tunnel” interface, which is an interface to functionality that encapsulates a data packet, which conforms to one protocol, into another data packet, which may conform to a different protocol. For example, a tunnel interface may be an interface to functionality that encapsulates an IPv4 packet into an IPv6 packet. For another example, a tunnel interface may be an interface to functionality that encapsulates an IPv6 packet into an IPv4 packet. A tunnel interface may encapsulate an IPv4 packet into an IPv4 packet, or an IPv6 packet into an IPv6 packet, or a Connectionless Network Service (CLNS) packet into an IPv4 packet, etc.
As is explained above, a data packet may be received on any one of a distributed router's cards' physical interfaces. According to one approach, in order to allow a data packet to be forwarded to a particular type of virtual interface regardless of which card's physical interface received the data packet, a separate virtual interface of the particular type is provided for each separate card. Each such virtual interface is associated with a separate pair of encapsulation and decapsulation chains. For example, given five separate cards, each card might provide a separate IPv4-to-IPv6 tunnel interface, and each card might implement a separate encapsulation chain and a separate decapsulation chain for each such IPv4-to-IPv6 tunnel interface, resulting in five separate IPv4-to-IPv6 encapsulation chains, and five separate IPv4-to-IPv6 decapsulation chains.
Unfortunately, under this approach, the encapsulation chains constructed for a particular type of virtual interface on some cards might never be used. For example, given five separate cards, there might not be any physical interfaces on the first card that are configured to send IPv6 data packets. Under these circumstances, the encapsulation chain associated with the IPv4-to-IPv6 tunnel interface for the first card would never be used.
Similarly, under this approach, the decapsulation chains constructed for a particular type of virtual interface for some cards might never be used. For example, given five separate cards, none of the physical interfaces on the second card might be configured to receive IPv4 data packets. Under these circumstances, the decapsulation chain associated with the IPv4-to-IPv6 tunnel interface for the second card would never be used.
Encapsulation and decapsulation chains use a card's limited memory and processing resources. Creating chains that will never be used wastes these limited resources, which might otherwise be used for other purposes.